import { postParam } from '@/utils/request'

export type GovernanceDffectivenessDataRequest = {
  /** 监管机构ID */
  entId: string
  /** 日期类型 - q: 季; m: 月; y: 年  */
  timeType: string
}

export type GovernanceDffectivenessOverivewData = {
  /** 环比 */
  hbPiont: number
  /** 同比 */
  tbPiont: number
}

export type GovernanceDffectivenessChartData = {
  xname: string
  ynum: { alarmNum: number; orderNum: number }
}

export type GovernanceDffectivenessDataResponse = {
  alarm: GovernanceDffectivenessOverivewData
  order: GovernanceDffectivenessOverivewData
  lineChart: GovernanceDffectivenessChartData[]
}

/**
 * 获取治理成效分析数据
 *
 * @param params
 * @returns
 */
export const getGovernanceDffectivenessData = async (
  params: GovernanceDffectivenessDataRequest
) => {
  const { data, suc, message } =
    await postParam<GovernanceDffectivenessDataResponse>(
      '/code/api/dp3/zlcxfx',
      params
    )

  if (suc) {
    return data
  } else {
    Promise.reject(message)
  }
}
